package mysql

import "gorm.io/gorm"

type Goods struct {
	gorm.Model
	UserId      int64   `gorm:"type:int;comment:用户id"`
	GoodsName   string  `gorm:"type:varchar(20);comment:商品名称"`
	GoodsPrice  float64 `gorm:"type:decimal(10,2);default:0.00;comment:价格"`
	GoodsStock  int64   `gorm:"type:int;comment:库存"`
	GoodsCover  string  `gorm:"type:varchar(200);not null;comment:封面"`
	GoodsStatus int64   `gorm:"type:tinyint(1);default:1;comment:状态:1:待出售,2:通过,3:不通过"`
}

func (g *Goods) Create() error {
	return Db.Create(&g).Error
}
func (g *Goods) GoodsInfo(goodsId int64) error {
	return Db.Model(&Goods{}).Where("id = ?", goodsId).Limit(1).Find(&g).Error
}
